package com.cr.command;

public class Client {
    public static void main(String[] args) {
        // 使用命令设计，完成通过遥控器对电灯的操作

        // 创建电灯的接收者
        LightReceiver lightReceiver = new LightReceiver();

        // 创建电灯相关的开关命令
        LightOnCommand lightOnCommand = new LightOnCommand(lightReceiver);
        LightOffCommand lightOffCommand = new LightOffCommand(lightReceiver);

        // 创建遥控器
        RemoteController remoteController = new RemoteController();
        // 给遥控器设置命令, 当 no = 0 是电灯的开和关操作
        remoteController.setCommand(0, lightOnCommand, lightOffCommand);

        System.out.println("-------按下灯开的按钮--------");
        remoteController.onButtonWasPushed(0);
        System.out.println("-------按下灯关的按钮--------");
        remoteController.offButtonWasPushed(0);
        System.out.println("-------按下撤销的按钮--------");
        remoteController.undoButtonWasPushed();

        System.out.println("====使用遥控器操作电视机========");

        TVReceiver tvReceiver = new TVReceiver();
        TVOnCommand tvOnCommand = new TVOnCommand(tvReceiver);
        TVOffCommand tvOffCommand = new TVOffCommand(tvReceiver);

        // 给遥控器设置命令, 当 no = 1 是电视机的开和关操作
        remoteController.setCommand(1, tvOnCommand, tvOffCommand);

        System.out.println("-------按下电视机开的按钮--------");
        remoteController.onButtonWasPushed(1);
        System.out.println("-------按下电视机关的按钮--------");
        remoteController.offButtonWasPushed(1);
        System.out.println("-------按下撤销的按钮--------");
        remoteController.undoButtonWasPushed();

    }
}
